<script setup lang="ts">
const emit = defineEmits(['close'])
const props = defineProps({
  title: String,
  current: String
})

const close = () => {
  emit('close', props.title)
}
</script>

<template>
  <div :class="{ tag: true, active: title === current }">
    <span class="text">{{ title }}</span>
    <span class="close" @click="close">×</span>
  </div>
</template>

<style scoped>
.tag {
  font-weight: 500;
  font-size: 14px;
  background: #FFF;
  width: fit-content;
  min-width: 50px;
  height: 30px;
  padding-left: 5px;
  border: 1px solid #e9ecf2;
  border-radius: 6px;
  white-space: nowrap;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  box-shadow: 3px 1px 3px #f4f4f4;
}

.active {
  color: #5d87ff;
}

.tag:hover {
  color: #5d87ff;
  background: #f0f7ff;
}

.text {
  flex-grow: 1;
  margin-left: 4px;
}

.close {
  margin-right: 2px;
  height: 20px;
  width: 20px;
  border-radius: 50px;
  text-align: center;
  line-height: 20px;
}

.close:hover {
  background-color: #e9ecf2;
  cursor: pointer;
}
</style>